﻿// <copyright file="AppSettingsService.cs" company="EffuEfface">
//      Copyright (c) Effu Efface Consulting  All rights reserved.
// </copyright>
// <author>$author$</author>

namespace TVersiPlay.Services
{
    using System;
    using System.Collections.Generic;
    using TVersiPlay.Common.Interfaces;
    using TVersiPlay.DTO;
    using Microsoft.Practices.Prism.Events;
    using TVersiPlay.Events;

    public class AppSettingsService: IAppSettingsService
    {
        #region declarations

        private IEventAggregator eventAggregator;

        private string upnpServerId;

        #endregion //declarations

        #region constructors

        public AppSettingsService(IEventAggregator eventAggregator) 
        {
            this.eventAggregator = eventAggregator;   
        }

        #endregion //constructors

        #region properties       

        #endregion //properties

        #region methods

        public void InitializeSettings(AppSettings settingsToInitialize)
        {
            this.upnpServerId = settingsToInitialize.UPnPServerId;
        }

        public void UpdateAndSaveAppSettings(AppSettings newAppSettingsToSave)
        {
            this.upnpServerId = newAppSettingsToSave.UPnPServerId;

            this.eventAggregator.GetEvent<SettingsUpdatedEvent>().Publish(newAppSettingsToSave);
        }

        public AppSettings GetAppSettings()
        {
            AppSettings myAppSettings = new AppSettings();
            myAppSettings.UPnPServerId = this.upnpServerId;

            return myAppSettings;
        }

        #endregion //methods

        #region events
        #endregion //events       
    }
}
